﻿@page "/slavedef"

@using BootstrapBlazor.Components
@using TrackSystem.UI.Server.Units
@using TrackSystem.UI.Server.Units.SlaveView


<div class="row g-3">
    <div class="col-6 col-sm-4 col-md-3 col-lg-auto">
        <h3>从站服务器定义</h3>
    </div>

    @if (changedStatus)
    {
        <div class="col-6 col-sm-4 col-md-3 col-lg-auto">
            <Button OnClick="@BtnCancel" Color="Color.Primary">取消</Button>
        </div>

        <div class="col-6 col-sm-4 col-md-3 col-lg-offset-3">
            <Button OnClick="@BtnSave" Color="Color.Info">保存</Button>
        </div>
    }
    else
    {
        <div class="col-6 col-sm-4 col-md-3 col-lg-auto">
            <Button OnClick="@BtnNewSlave" Color="Color.Primary">新建</Button>
        </div>

        <div class="col-6 col-sm-4 col-md-3 col-lg-auto">
            <Button OnClick="@BtnDeleteSlave" Color="Color.Info">删除</Button>
        </div>

        <div class="col-6 col-sm-4 col-md-3 col-lg-auto">
            <Button OnClick="@BtnEnterChanged" Color="Color.Primary">编辑</Button>
        </div>
    }
</div>

<Divider></Divider>

@if (_listSlaves is not null && _listSlaves.Any() )
{
    if (pageOptions.CurrentPage <= _listSlaves.Count && pageOptions.CurrentPage != -1)
    {
        if (changedStatus)
        {
            <SlaveDefChanged Slave="_listSlaves[pageOptions.CurrentPage - 1]" RegNames="_regNames"></SlaveDefChanged>
        }
        else
        {
            <SlaveDefDisp Slave="_listSlaves[pageOptions.CurrentPage -1]"></SlaveDefDisp>
        }
    }
}

@if (!changedStatus)
{
    <Divider />
    <Pagination PageCount="@pageOptions.TotalPages" OnPageLinkClick="@OnPageClick" Alignment="Alignment.Center" />
}

<Divider/>
<p>@_sMsg</p>



